const lodash = require('lodash/lodash')
const mapDeep = require('deepdash/getMapDeep')(lodash)
const treeData = require('./treeData')

const node = {
  name: 'level2',
  value: 2
}

const propMap = {
  keyProp: 'value',
  childrenProp: 'children',
  includeSelf: true
}

function findLeaves (treeData) {
  const deepOptions = {
    childrenPath: 'children',
    leavesOnly: true
  }
  return mapDeep(treeData, val => val, deepOptions)
}


const leaves = findLeaves(treeData, node, propMap)

console.log(`all leaves: \n`, leaves)
